package kstech.com.md5generate;

import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
    private boolean compareDate(){
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm");
        try {
            Date d1 = df.parse("2017-03-31 00:00:00");
            if(System.currentTimeMillis()<d1.getTime()){
                return true;
            }
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return false;

    }
    public void generate(View view) {
        if(compareDate()){
            String s = MD5Utils.getMac();
            s = MD5Utils.md5(s);
            MD5Utils.generateMD5(s);
            Toast.makeText(this,"检测设备已激活",Toast.LENGTH_SHORT).show();
        }else {
            Toast.makeText(this,"软件已过期，请及时联系开发人员",Toast.LENGTH_SHORT).show();
        }

    }

    public void finish(View view) {
        this.finish();
    }

    public void wifilisten(View view) {

    }
}
